package com.zyz.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zyz.service.UserServiceD2;

@RestController
@RequestMapping("/user")
public class TestController {
    @Autowired
    private UserServiceD2 userService;
    @RequestMapping("/test")
    public String getUserById() {
        StringBuilder sb = new StringBuilder();
        try {
            sb.append("getUserById(1): ").append(userService.getUserById(1)).append("\n");
        } catch (Exception e) {
            return "调用 getUserById(1) 异常：" + e.getMessage();
        }
        try {
            sb.append("getUserById(-1): ").append(userService.getUserById(-1)).append("\n");
        } catch (Exception e) {
            return "调用 getUserById(-1) 异常：" + e.getMessage();
        }
        try {
            userService.getUserById(-1);
        } catch (Exception e) {
            return "调用 getUserById(-1) 异常：" + e.getMessage();
        }
        return sb.toString();
    }
}
